package com.my.study.designPatterns.singlePattern;

/**
 * 双重检查加锁，在getInstance（）中减少使用同步， 效率比SingleSynchronized高
 */
public class SingleDoubleCheck {

    private static volatile SingleDoubleCheck instance;


    private SingleDoubleCheck(){

    }

    public static SingleDoubleCheck getInstance(){

        if(instance == null){
            synchronized (SingleDoubleCheck.class){

                instance = new SingleDoubleCheck();
            }
        }
        return instance;
    }
}

